package com.rmfyzxfw.caseprocess.enums;

import lombok.Getter;

@Getter
public enum DynamicDatabaseTypeEnum {
    MYSQL(1, "mysql", "MySql数据库", "com.mysql.cj.jdbc.Driver"),
    OCEAN_BASE(2, "oceanbase", "OceanBase数据库", "com.oceanbase.jdbc.Driver"),
    ORACLE(3, "oracle", "oracle数据库", "oracle.jdbc.driver.OracleDriver"),
    ;
    private Integer code;
    private String name;
    private String desc;
    private String driver;

    DynamicDatabaseTypeEnum(Integer code, String name, String desc, String driver) {
        this.code = code;
        this.name = name;
        this.desc = desc;
        this.driver = driver;
    }

    public static DynamicDatabaseTypeEnum ofCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (DynamicDatabaseTypeEnum value : values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return null;
    }
}
